package com.codemeta.bokit.props.config;

import com.codemeta.bokit.props.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Objects;

/**
 * 常用组件配置文件自动装配
 *
 * @author hice
 * @date 2023/04/27
 */
@Slf4j
@Configuration
@EnableConfigurationProperties(DataSourceProperties.class)
public class PropsAutoConfig {

    @Bean
    @ConditionalOnMissingBean(CommProps.class)
    public CommProps commProps() {
        CommProps props = new CommProps();
        log.debug("【bokit】注入comm配置对象：{}", Objects.hashCode(props));
        return props;
    }

    @Bean
    @ConditionalOnMissingBean(WebProps.class)
    public WebProps webProps() {
        WebProps props = new WebProps();
        log.debug("【bokit】注入web配置对象：{}", Objects.hashCode(props));
        return props;
    }

    @Bean
    @ConditionalOnMissingBean(WebXssProps.class)
    public WebXssProps webXssProps() {
        WebXssProps props = new WebXssProps();
        log.debug("【bokit】注入web-xss配置对象：{}", Objects.hashCode(props));
        return props;
    }

    @Bean
    @ConditionalOnMissingBean(MybatisProps.class)
    public MybatisProps mybatisProps() {
        MybatisProps props = new MybatisProps();
        log.debug("【bokit】注入mybatis配置对象：{}", Objects.hashCode(props));
        return props;
    }

    @Bean
    @ConditionalOnMissingBean(SecurityProps.class)
    public SecurityProps securityProps() {
        SecurityProps props = new SecurityProps();
        log.debug("【bokit】注入security配置对象：{}", Objects.hashCode(props));
        return props;
    }

    @Bean
    @ConditionalOnMissingBean(FlowableProps.class)
    public FlowableProps flowableProps() {
        FlowableProps props = new FlowableProps();
        log.debug("【bokit】注入flowable配置对象：{}", Objects.hashCode(props));
        return props;
    }

    @Bean
    @ConditionalOnMissingBean(SocialProps.class)
    public SocialProps socialProps() {
        SocialProps props = new SocialProps();
        log.debug("【bokit】注入social配置对象：{}", Objects.hashCode(props));
        return props;
    }

}